home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!usenet
- From: GHouck <hksys@teleport.com>
- Newsgroups: comp.lang.c
- Subject: Re: Character string
- Date: 12 Apr 1996 03:41:16 GMT
- Organization: systems hk
- Message-ID: <4kkjcs$c32@nadine.teleport.com>
- References: <4kil74$8i7@Tandem1.opennet.net.au> <4kja1d$7fm@spanky.pls.ov.com>
- NNTP-Posting-Host: ip-pdx08-22.teleport.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- glenn@ov.com (Fletcher.Glenn@ov.com) wrote:
- >>How do I do a similar statement in C to the Pascal code:
- >>
- >>If Ch IN ['a','A'] THEN
- >>
- >>I know I can use if (ch=='a') && (ch=='A') but was looking for something
- >>a little more ellegant.
- >>
- >
- >For small tests (like two characters) you cannot beat the if test. For
- >filtering among many characters, the code can be made much more understandable
- >using the switch() statement. switch() allows you to identify various
- >responses to input values on a case by case basis. See your local C book.
- >
-
- Ken,
- Also, if what you're interested in is accommodating the upper and lower
- case characters at same time, how about using:
-
- if( toupper(ch) == 'A' ) {
-
- or
-
- switch( toupper(ch) ) {
-
- Yours, Geoff Houck
-
-